export default {
	props:{
		flag:Boolean,
		approveStateList:Array
	},
    data(){
        return{
			searchObj: {
			    name:'',
			    //checkDateStr: '',
				daterange:[],
			},
            listData:{
                pageNum:1,//页码
                pageSize:20,
                total:5,//总共条数
                data:[]
            },
            showDialog:false,
			rowId:"",
            
        }
    },
	watch:{
		flag(val){
			if(val){
				this.getListData()
			}
		},
		approveStateList(){
			if(this.flag && this.listData.data.length==0){
				this.getListData()
			}
		}
	},
    methods:{
        getListData(pageNum){
            var submitData={
                current:typeof pageNum=='number' ? pageNum : this.listData.pageNum,
                size:this.listData.pageSize,
                ...this.searchObj,
            };
			if(submitData.daterange){
				submitData.startDate=submitData.daterange[0]
				submitData.endDate=submitData.daterange[1]
				delete submitData.daterange
			}
            this.$http[this.apiMethod](submitData)
            .then((res)=>{
                var data=res.data.data;
                this.$set(this.listData,'pageNum',data.current);
                this.$set(this.listData,'pageSize',data.size);
                this.$set(this.listData,'total',data.total);
                this.$set(this.listData,'data',this.transData(data.records))

            }).catch((err)=>{
                throw(err)
            })
        },


        viewDetail(rowData){
            this.showDialog=true;
			this.$nextTick(()=>{
				this.rowId=rowData.row.id
			})
        },
		
		transData(data){
			data.forEach((item)=>{
				this.approveStateList.forEach((item1)=>{
					if(item.status==item1.code){
						item.statusName=item1.name
					}
				})
			})
			return data;
		},
		
    },
	

}